package com.example.sneakerappserver.repository;

import com.example.sneakerappserver.pojo.Order;
import com.example.sneakerappserver.pojo.User;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface OrderRepository extends CrudRepository<Order,Long> {
    @Query(value = "SELECT * FROM tb_order WHERE order_id = :orderId", nativeQuery = true)
    Order findByOrderId(Long orderId);

    @Query(value = "SELECT * FROM tb_order WHERE user_id = :userId", nativeQuery = true)
    List<Order> findByUserId(Long userId);

    @Query(value = "SELECT * FROM tb_order WHERE user_id = :userId AND status = :status", nativeQuery = true)
    List<Order> findByUserIdAndStatus(Long userId,String status);

    @Query(value = "SELECT * FROM tb_order WHERE  status = :status", nativeQuery = true)
    List<Order> findByStatus(String status);
}
